﻿namespace Probel.NDoctor.Statistics.UnitTests.Helpers
{
    using System;
    using System.Collections.Generic;

    using Probel.NDoctor.Statistics.Domain;

    internal static class Data
    {
        #region Fields

        public static readonly Guid AppKey = Guid.NewGuid();
        public static readonly DateTime Today = DateTime.Today;

        #endregion Fields

        #region Properties

        public static Application Application
        {
            get
            {
                return new Application()
                {
                    ApplicationKey = AppKey,
                    InstallationDate = Today,
                    LastUpdate = Today,
                    UpdateVersion = Today,
                    Version = "2.0.0",
                };
            }
        }

        public static IEnumerable<Application> Applications
        {
            get
            {
                var apps = new List<Application>();
                for (int i = 0; i < 6; i++)
                {
                    var date = Data.Today.AddDays(-10 - i);
                    apps.Add(new Application()
                    {
                        LastUpdate = date,
                        InstallationDate = date,
                        ApplicationKey = (i == 0) ? Data.AppKey : Guid.NewGuid(),
                        Version = "1.2.3.4"
                    });
                }
                return apps;
            }
        }

        public static IEnumerable<SessionDuration> Durations
        {
            get
            {
                var durations = new List<SessionDuration>();
                for (int i = 0; i < 10; i++)
                {
                    durations.Add(new SessionDuration()
                    {
                        Duration = new TimeSpan(0, 0, 15, 0, 0),
                        TimeStamp = DateTime.Now.AddDays(-i),
                        Version = "1.0.0.2",
                    });
                }
                return durations;
            }
        }

        public static string RandomString
        {
            get { return Guid.NewGuid().ToString(); }
        }

        public static IEnumerable<StatisticEntry> Statistics
        {
            get
            {
                var stat = new List<StatisticEntry>();
                for (int i = 0; i < 10; i++)
                {
                    stat.Add(new StatisticEntry()
                    {
                        ExecutionTime = 10,
                        Threshold = 5,
                        IsPossibleBottleneck = (i % 2 == 0),
                        MethodName = Data.RandomString,
                        TargetTypeName = Data.RandomString,
                        TimeStamp = Data.Today
                    });
                }
                return stat;
            }
        }

        #endregion Properties
    }
}